<?
$pathPrefix = "../..";
if (PHP_OS == "Linux") {
	$pathPrefix = "/var/www/masoCoach/phpMain";
}
?>
<?php include($pathPrefix . "/includes/includes.php"); ?>
<?php
connect($config);
$leagues = getActiveLeagues();

expirePicks($leagues);

informTrades($leagues);

informTeamsSubmitted($leagues);

informLtiDelist($leagues);

$currentRoundStatusOld = getCurrentRoundStatus();
updateRoundStatus($config->hours);
$currentRoundStatusNew = getCurrentRoundStatus();
$coachesNotSubmittedTeam = retrieveCoachIDsNotSubmittedTeams();
if ($currentRoundStatusOld == RoundStatusType::Open && $currentRoundStatusNew == RoundStatusType::Partial_Lockout) {
	insertBulkPenalty(implode(",", $coachesNotSubmittedTeam), getCurrentRound(), "PARTIAL");
	setDefaultTeams($coachesNotSubmittedTeam);
}
else if (($currentRoundStatusOld == RoundStatusType::Open || $currentRoundStatusOld == RoundStatusType::Partial_Lockout) && $currentRoundStatusNew == RoundStatusType::Lockout) {
	insertBulkPenalty(implode(",", $coachesNotSubmittedTeam), getCurrentRound(), "FULL");
	setDefaultTeams($coachesNotSubmittedTeam);
}
processSelectedTeams($config->hours, false);
if (determineIfNeedSendReminders($config->hours)) {
   sendTeamReminders($leagues);
}
$uploadedSomething = getScores($config->hours, false);
if ($uploadedSomething) {
	informResultsUpdated($leagues);
	
    if (getNumberOfTeamsSubmitted(getCurrentRound()) == 18) {
	   	finaliseRound();
    }
}
mysql_close();
?>